package com.learn.servloader;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

@Service
public class ParseClientV2 {

    private ParserFactory parserFactory;
    private Reader reader;

    @Autowired
    public ParseClientV2(ParserFactory parserFactory) {
        this.parserFactory = parserFactory;
    }

    public void setReader(Reader reader) {
        this.reader = reader;
    }

    /**
     * 核心就是通过参数名称（实际上是容器bean的beanName）找到对应的实例，然后调用其对用方法；
     *
     * @param contentTypeV2
     * @return
     */
    public List getAll(ContentTypeV2 contentTypeV2) {
        List parse = parserFactory.getParser(contentTypeV2).parse(reader);
        return new ArrayList<>();
    }

}
